#!/usr/bin/env python
# $Id: nodetest.py ddcad87fab9c 2013/08/17 19:20:30 pgurumur $
# Copyright (c) 2013 Prabhu Gurumurthy <pgurumur@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# File nodetest.py generated on Mon, July 29, 2013 16:17:08 PM
#
from __future__ import division

__version__  = "$Revision: ddcad87fab9c $"
__author__   = "$Author: pgurumur $"
__modified__ = "$Date: 2013-08-17 19:20:30Z $"

import math
import sys
sys.path.append("../")

from emerald.lib import base, stdlib

# import node

"""
nf_test1 = base.BerylFloat(3.12)
fl_test1 = 3.12
print(nf_test1, fl_test1)

nf_test1 += 2
fl_test1 += 2
print(nf_test1, fl_test1)

nf_test1 += 3.456
fl_test1 += 3.456
print(nf_test1, fl_test1)

nf_test1 *= 4
fl_test1 *= 4
print(nf_test1, fl_test1)

nf_test1 /= 4
fl_test1 /= 4
print(nf_test1, fl_test1)

teststr = "2.345"
try:
   nf_test1 += teststr
except TypeError as err:
   print("node float", err)
else:
   print(nf_test1)

try:
   fl_test1 += teststr
except TypeError as err:
   print("real float", err)
else:
   print(fl_test1)

nf_test1 += 4.56
print(nf_test1)

nf_test2 = node.BerylFloat(3.12)
print(nf_test2)

nf_test2 += 4.56
print(nf_test2)

nf_test3 = node.BerylVariable(3)
nf_test4 = node.BerylVariable(3.14)
nf_test5 = node.BerylVariable("foobar")
nf_test6 = node.BerylVariable(pow(2, 128))
nf_test7 = node.BerylVariable("22")

temp = nf_test3 + 3
print(temp.value, type(temp))
temp += nf_test4
print(temp, temp.value)
temp += 4.56
print(temp, temp.value)
a_test = temp / 2.789
print(a_test)
print(int(a_test))
print(hash(a_test))
print(float(nf_test7))
print(type(a_test))
print(id(a_test))

nf_test5 += "3.45"
print(nf_test5)
nf_test5.name = "foobar"
print(nf_test5)

print(nf_test5[2:5])
"""

test1 = base.BerylVariable(15.45)
test1.name = "var_a"
test1 += 4.5
print(test1)

main = base.BerylNamespace("__main__")
main.Add(test1)
print(main)
print(main.FindVar("var_a"))

test2 = base.BerylVariable("foobar")
test2.name = "var_b"
main.Add(test2)
print(main.FindVar("var_b"))

print(test1.parent, test2.parent)
main([])
main(stdin = True)
main(filename = "foobar", stdin = False)
